<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/6/2
  Time: 16:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>

<div class="row">
  <div class="col-lg-12">
    <div class="panel">
      <div class="panel-heading header">
        <h3 class="panel-title" id="title">订单跟踪表</h3>
      </div>
<form id="form_ordertrack_input" class="panel-body form-horizontal form-padding">
  <input type="hidden" name="keyId" id="keyId" value="${orderTrack.id}" />
  <%--<input type="hidden" name="family" id="family"  />--%>
  <input type="hidden" name="parentId" id="parentId" value="${parentId}" />
  <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

  <div class="form-group" id="tempWidth1">
    <label class="col-md-2 control-label">订单编号<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input disabled type="number" id="orderNo" name="orderNo" class="form-control" placeholder="请输入订单编号" value="${orderTrack.orderEntity.orderNo}">
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单下达时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input disabled type="text" class="form-control" id="issuedDate" name="issuedDate" placeholder="请选择订单下达时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderEntity.issuedDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">期望交付时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input disabled type="text" class="form-control" id="deliverDate" name="deliverDate" placeholder="请选择期望交付时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderEntity.deliverDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单跟踪时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input type="text" class="form-control" id="trackDate" name="trackDate" placeholder="请选择订单跟踪时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.trackDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单完成比率<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group">
        <input type="number" class="form-control" id="rate" name="rate" placeholder="请输入订单完成比率" value="${orderTrack.rate}" >
        <span class="input-group-addon">%</span>
      </div>
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 control-label">完成情况说明<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input type="text" id="completion" name="completion" class="form-control" placeholder="请输入完成情况说明" value="${orderTrack.completion}">
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 control-label">是否有障碍问题<i class="fa fa-asterisk txt-color-red"></i>
    </label>
    <div class="col-md-6">
      <div class="radio">
        <!-- Inline radio buttons -->
        <input type="radio" name="difficulty" id="difficulty1Selected" class="magic-radio" value="2"
        <c:if test="${orderTrack.difficulty eq 2}"> checked="checked"</c:if> >
        <label for="difficulty1Selected">是</label>

        <input type="radio" name="difficulty" id="difficulty2Selected" class="magic-radio" value="1"
        <c:if test="${orderTrack.difficulty eq 1}"> checked="checked"</c:if> >
        <label for="difficulty2Selected">否</label>

      </div>
    </div>
  </div>

  <div class="form-group" id="showDifficultyText" <c:if test="${orderTrack.difficulty==0||orderTrack.difficulty==1}">style="display: none"</c:if>>
    <label class="col-md-2 control-label">障碍情况描述<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input type="text" id="difficultyText" name="difficultyText" class="form-control" placeholder="请输入障碍情况描述" value="${orderTrack.difficultyText}">
    </div>
  </div>

  <div class="form-group" id="showOvercome" <c:if test="${orderTrack.difficulty==0||orderTrack.difficulty==1}">style="display: none"</c:if>>
    <label class="col-md-2 control-label">障碍克服情况<i class="fa fa-asterisk txt-color-red"></i>
    </label>
    <div class="col-md-6">
      <div class="radio">
        <!-- Inline radio buttons -->
        <input type="radio" name="overcome" id="overcome1Selected" class="magic-radio" value="2"
        <c:if test="${orderTrack.overcome eq 2}"> checked="checked"</c:if> >
        <label for="overcome1Selected">已克服</label>

        <input type="radio" name="overcome" id="overcome2Selected" class="magic-radio" value="1"
        <c:if test="${orderTrack.overcome eq 1}"> checked="checked"</c:if> >
        <label for="overcome2Selected">未克服</label>

      </div>
    </div>
  </div>


  <div class="form-group">
    <label class="col-md-2 control-label">提交人</label>
    <div class="col-md-2">
      <p class="form-control-static">${orderTrack.creater.name}</p>
    </div>
    <label class="col-md-2 control-label">提交日期</label>
    <div class="col-md-2">
      <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.createTime}" /></p>
    </div>
  </div>

  <div class="panel-footer">
    <a class="btn btn-default" id="apply-re-common2" href="javascript:void(0)">
      <i class="fa fa-lg fa-mail-reply"></i> 返回
    </a>
    <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
    <c:if test="${orderTrack==null || orderTrack.processState=='Draft'}">
      <a class="btn btn-warning" id="btn-commit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
    </c:if>
    <c:if test="${orderTrack!=null && orderTrack.processState=='Backed'}">
      <a class="btn btn-warning" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
    </c:if>
  </div>

</form>
    </div>
  </div>
</div>
<!--===================================================-->
<!-- END BASIC FORM ELEMENTS -->

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";

  $(function(){
    var pdata= {
      keyId:$("#form_ordertrack_input #keyId").val(),
      entityName:"com.fz.us.oa.core.entity.com.OrderTrack"
    };
    multiDuty(pdata);
  });

  // 日期选择
  $('.input-group.date').datepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    todayHighlight: true,
    language: 'zh-CN'
  });

  //显示隐藏
  $(":radio[name='difficulty']").click(function(){
    if($(this).val()==1){
      $("#showDifficultyText").hide();
      $("#showOvercome").hide();
    }else{
      $("#showDifficultyText").show();
      $("#showOvercome").show();
    }
  });

  //校验
  function infoValidate() {
    var tmp = "";

    tmp = $("#form_ordertrack_input #trackDate").val();
    if(!tmp){
      __toastr_error("请选择订单跟踪时间！");
      return false;
    }

    tmp = $("#form_ordertrack_input #rate").val();
    if(!tmp){
      __toastr_error("请输入订单完成比率！");
      return false;
    }else if(tmp<=0||tmp>100){
      __toastr_error("完成比率请输入1~100之间的数！");
      return false;
    }else if(!(/(^[1-9]\d*$)/.test(tmp))){
      __toastr_error("请输入一个整数！");
      return false;
    }

    tmp = $("#form_ordertrack_input #completion").val();
    if(!tmp){
      __toastr_error("请输入完成情况说明！");
      return false;
    }

    var tmp=$("#form_ordertrack_input input:radio[name='difficulty']:checked").val();
    if(tmp==2){
      var tmp2 = $("#form_ordertrack_input #difficultyText").val();
      if(!tmp2){
        __toastr_error("请输入障碍情况描述！");
        return false;
      }
    }

    return true;
  }

  //保存
  $("#btn-save-common").click(
          function(e) {
            __confirm_dialog("提示：","确定保存吗？",
                    function () {
                      __form_save("form_ordertrack_input", "<%=path%>/com/orderTrack/save",function(){
                        $("#apply-re-common2").trigger("click");
                      });
                    }
            )
          }
  );

  //提交
  $("#btn-commit-common,#btn-recommit-common").click(
          function(e) {
            var $valid = infoValidate();
            if(!$valid) return false;

            __confirm_dialog("提示：","提交后填写资料不得修改，请确认是否进行提交？",
                    function () {
                      __form_save("form_ordertrack_input", "<%=path%>/com/orderTrack/submit",function(){
                        $("#apply-re-common2").trigger("click");
                      });
                    }
            )
          }
  );

  //返回视图
  $("#apply-re-common2").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      toRewardList()
    }
  });
  function toRewardList(){
    var parentId=$("#form_order_input #keyId").val();
    var table_global_width = $("#s1").is(":visible") ? $("#s1").width() : $("#s2").width();
    $('div').data("table_global_width", table_global_width);
    loadURL("<%=path%>/com/orderTrack/toList?parentId="+parentId,$('#s2'));
  }

</script>